//
//  TTDetailInfoViewCell.m
//  TaoTuo
//
//  Created by admin on 2019/8/24.
//  Copyright © 2019 admin. All rights reserved.
//

#import "TTDetailInfoViewCell.h"

@interface TTDetailInfoViewCell ()

@property (nonatomic, strong) UILabel *leftTitleLabel;
@property (nonatomic, strong) UILabel *leftContentLabel;

@property (nonatomic, strong) UILabel *rightTitleLabel;
@property (nonatomic, strong) UILabel *rightContenLabel;

@end

@implementation TTDetailInfoViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.backgroundColor = [UIColor whiteColor];
        
    }
    return self;
}

- (void)setDic:(NSDictionary *)dic
{
    _dic = dic;
    
    self.leftTitleLabel.text = dic[@"leftTitle"];
    self.leftContentLabel.text = dic[@"leftContent"];
    self.rightTitleLabel.text = dic[@"rightTitle"];
    self.rightContenLabel.text = dic[@"rightContent"];
    
    if (self.rightTitleLabel.text.length == 0) {
        [self.leftContentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView).mas_offset(-10);
        }];
    } else {
        [self.leftContentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
            make.right.lessThanOrEqualTo(self.contentView.mas_centerX).mas_offset(20);
        }];
    }
    
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    [self.leftTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).mas_equalTo(10);
        make.height.equalTo(self.contentView);
    }];
    
    [self.leftContentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.leftTitleLabel.mas_right);
        make.right.lessThanOrEqualTo(self.contentView.mas_centerX).mas_offset(20);
        make.height.equalTo(self.leftTitleLabel);
    }];
    
    [self.rightTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_centerX).mas_offset(22);
        make.height.equalTo(self.contentView);
    }];
    
    [self.rightContenLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.rightTitleLabel.mas_right);
        make.right.lessThanOrEqualTo(self.contentView).mas_offset(-10);
        make.height.equalTo(self.leftTitleLabel);
    }];
    
}

- (UILabel *)leftTitleLabel
{
    if (!_leftTitleLabel) {
        _leftTitleLabel = [UILabel labelWithTitle:@"" color:UIColorHex(666666) fontSize:14];
        [self.contentView addSubview:_leftTitleLabel];
    }
    return _leftTitleLabel;
}

- (UILabel *)leftContentLabel
{
    if (!_leftContentLabel) {
        _leftContentLabel = [UILabel labelWithTitle:@"" color:UIColorHex(666666) fontSize:14];
        [self.contentView addSubview:_leftContentLabel];
    }
    return _leftContentLabel;
}


- (UILabel *)rightTitleLabel
{
    if (!_rightTitleLabel) {
        _rightTitleLabel = [UILabel labelWithTitle:@"" color:UIColorHex(666666) fontSize:14];
        [self.contentView addSubview:_rightTitleLabel];
    }
    return _rightTitleLabel;
}

- (UILabel *)rightContenLabel
{
    if (!_rightContenLabel) {
        _rightContenLabel = [UILabel labelWithTitle:@"" color:UIColorHex(666666) fontSize:14];
        [self.contentView addSubview:_rightContenLabel];
    }
    return _rightContenLabel;
}


@end
